package reflect;

import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;

/**
 * 通过反射机制实例化对象
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner scan  = new Scanner(System.in);
        System.out.println("请输入类名：");
        String className = scan.next();
        Class cls = Class.forName(className);

        Object obj = cls.newInstance();
        System.out.println(obj);

        ArrayList list = new ArrayList();
        System.out.println(list);
    }
}
